﻿using Microsoft.Xna.Framework.Input;

namespace Jv.Games.Engine
{
	public static class Keyboard
	{
		#region Properties
		static KeyboardState OldState { get; set; }
		static KeyboardState CurrentState { get; set; }
		#endregion

		public static bool Press(Keys key)
		{
			return CurrentState[key] == KeyState.Down && OldState[key] == KeyState.Up;
		}

		public static bool Hold(Keys key)
		{
			return CurrentState[key] == KeyState.Down;
		}

		public static bool Release(Keys key)
		{
			return OldState[key] == KeyState.Down && CurrentState[key] == KeyState.Up;
		}

		#region Internal Methods
		internal static void Update()
		{
			OldState = CurrentState;
			CurrentState = Microsoft.Xna.Framework.Input.Keyboard.GetState();
		}
		#endregion
	}
}
